<?php
class kernel extends meccanoFilters
{
   private $DB            = NULL;
   private $types         = array();

   protected function __construct()
   {
      parent::__construct();

      $this->DB     = database::getInstance();

      if(!$this->ERROR->getErrorStatus())
      {
         # TYPES LOADER
         $this->DB->sql = 'SELECT * FROM `meccano_types`';
         $this->DB->DB_Fetch();
         for($i=0, $t=$this->DB->rows; $i<$t; $i++)
         {
            $this->types[$this->DB->fetched[$i]['type']][$this->DB->fetched[$i]['id']] = $this->DB->fetched[$i]['name'];
         }
      }
   }

   static public function getInstance()
   {
      static $object_store_singelton;
      if(!is_object($object_store_singelton))
      {
         $object_store_singelton = new kernel();
      }
      return $object_store_singelton;
   }


   /**
    * Get registered types
    * @param string $type (can be: 'a','c','f','g','b')
    * @return array
    */
   final public function getTypes($type = false)
   {
      if($type && isset($this->types[$type])) return $this->types[$type];
      if($type) return array();
      return $this->types;
   }
}